package cn.zhaozhiqi.autoconfiguration;

import cn.zhaozhiqi.properties.TencentProperties;
import cn.zhaozhiqi.template.TencentMapTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
@EnableConfigurationProperties({TencentProperties.class})
public class MapAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(RestTemplate.class)//如果容器中没有该实例，就创建一个给容器
    public RestTemplate get(){
        return new RestTemplate();
    }
    @Bean
    public TencentMapTemplate getTencent(TencentProperties properties,RestTemplate restTemplate){
            return new TencentMapTemplate(properties,restTemplate);
    }

}
